#include <string>
#include <iostream>
#include <ctime>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;
//#define FUCK



int sxiao(int a,int b,int v[],int len,int flag[]){
    int ans=0;
    for(int i=a;i>=0;i--){
        if(!flag[i]){
            a=i; //第一个 flag=0
            break;
        } 
    }
    for(int i=b;i<len;i++){
        if(!flag[i]) {
            b=i;
            break;
        }
    }
    if(a<=0 && b>=len-1){
        return 0;
    }
    if(v[a]==v[b]){
        
        int f=0,f1=1,ans1=0,ans2=0,ans3=0;
        
        if(a-1>=0&& b+1<=len-1&& v[a]==v[a-1]&&v[b+1]==v[a-1]){
            flag[a]=flag[b]=flag[a-1]=flag[b+1]=1;
            ans3=4+sxiao(a-1,b+1,v,len,flag);
            f1=0;
        }
        
        if(f1&&a-1>=0 && v[a-1]==v[a]&&!flag[a-1]){
            f=1;
            flag[a]=flag[b]=flag[a-1]=1;
            
            ans1=3+sxiao(a-1,b,v,len,flag);
        }
        //cout << "a "<<a << " b "<< b<< " ans1 "<< ans1 <<endl; 

        if(f1&&b+1<=len-1 && v[b+1]==v[b] && !flag[b+1]){
            if(f) {
                flag[a]=flag[b]=flag[a-1]=0;
            }
            flag[a]=flag[b]=flag[b+1]=1;
            
            ans2=3+sxiao(a,b+1,v,len,flag);
            
        }

        
        //cout << "a "<<a << " b "<< b<< " ans2 "<< ans2 <<endl; 

        ans=max(ans,max(ans3,max(ans1,ans2)));
    }

    return ans;
}

int xiao(int x,int v[],int len,int flag[]){
    int ans=2;
    flag[x]=flag[x+1]=1;
    
    // cout << "-----------------------"<<endl;
    int xx=sxiao(x,x+1,v,len,flag);
    // cout <<"x :" <<x<<" sxiao: " << xx <<endl;
    // cout << "-----------------------"<<endl;
    ans+=xx;
    return ans;
}
void method1(){
    int n;
    while(cin >>n){
        int v[n];
        for(int i=0;i<n;i++){
            cin >>v[i];
        } //统计次数
        //2个的下标
        vector<int> t;
        for(int i=0;i<n-1;i++){
            if(v[i]==v[i+1]){
                t.push_back(i);
                i++;
            }
        }
        int ans=n;
        int flag[n+1];
        for(auto i=t.begin();i!=t.end();i++){
            memset(flag,0,sizeof(flag));
            int x=xiao(*i,v,n,flag); //返回消去的最长长度
            ans=min(ans,n-x);
        }
        cout <<ans <<endl;
    }


}


/*

*/

int main(){
#ifdef FUCK
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    int start=clock();
#endif
    method1();



#ifdef FUCK
    int end=clock();
    double p=(double)(end-start)/CLOCKS_PER_SEC;
    cout << "运行时间为 : "<<p*1000 <<" ms"<<endl;
#endif
    return 0;
}